package com.kfm.base.array2;

public class Demo16 {

    public static void main(String[] args) {
        /*
            多维数组排序
               每个同学有三门课的成绩（语文/数学/政治）分别是数组的 1 2 3 个元素
              一个班有 5 个同学，按他们的语文成绩输出每个同学的各科成绩

              92 96 99
              94 90 87

         */

        int[][] scores = {
                {78, 89, 93},
                {88, 92, 89},
                {79, 87, 88},
                {92, 96, 99},
                {94, 90, 87}
        };

        // 对数组排序
        for (int i = 0; i < scores.length - 1; i++) {
            for (int j = 0; j < scores.length - 1 - i; j++) {
                if (scores[j][0] < scores[j + 1][0]){
                    int[] temp = scores[j];
                    scores[j] = scores[j + 1];
                    scores[j + 1] = temp;
                }
            }
        }        



        // 遍历输出
        for (int i = 0; i < scores.length; i++) {
            for (int j = 0; j < scores[i].length; j++) {
                System.out.print(scores[i][j] + "\t");
            }
            System.out.println();
        }
    }
}
